/*
 *   This File is Part of CuteOgre Game Engine
 *
 *   This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 *
 *	Copyright 2010 Alexandre Pires ( c.alexandre.pires@gmail.com )
 *  Created on: 2010/08/22
 */

#ifndef RENDERMANAGER_H_
#define RENDERMANAGER_H_

#include "IManager.h"
#include <Singleton.h>

#include <OGRE/OgreRenderWindow.h>
#include <OGRE/OgreCamera.h>
#include <OGRE/OgreRoot.h>
#include <OGRE/OgreSceneManager.h>

class RenderManager :
		public IManager,
		public Singleton<RenderManager> {
public:
	enum RenderMode {
		ModeIdle = 0x0, ModeVideoPlayback = 0x1, ModeGui = 0x2
	};

friend class GameEngine;

private:
	Ogre::Root* mRoot;
	Ogre::RenderWindow* mWindow;
	Ogre::SceneManager* mCurrentSceneMgr;
	Ogre::Camera* mCurrentCamera;
	bool mShutdown;
	RenderMode mRenderMode;

protected:

	RenderManager() : mShutdown(true) {
	}

public:
	~RenderManager() {
	}

	inline Ogre::SceneManager* getSceneManager() {

		return mCurrentSceneMgr;
	}

	inline Ogre::RenderWindow* getRenderWindow() {
		return mWindow;
	}

	inline Ogre::Root* getRoot () {
		return mRoot;
	}

	inline RenderMode getCurrentMode() {
		return mRenderMode;
	}

	static RenderManager* getSingletonPtr(void) {
		return ms_Singleton;
	}

	static RenderManager& getSingleton(void) {
		assert( ms_Singleton );
		return (*ms_Singleton);
	}

	void init ();
	void shutdown ();
	void switchToMode ( RenderMode rMode, bool rSameCamera = false );
	void update ();
};

#endif /* RENDERMANAGER_H_ */
